package com.serkol.ams.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.entity.LoginLog;
import com.serkol.ams.entity.UsersSignLog;
import com.serkol.ams.mapper.UsersSignLogMapper;
import com.serkol.ams.service.UsersSignLogService;
import com.serkol.constant.AuthConstant;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author pingan
* @description 针对表【users_sign_log】的数据库操作Service实现
* @createDate 2022-10-05 23:26:08
*/
@Service
public class UsersSignLogServiceImpl extends ServiceImpl<UsersSignLogMapper, UsersSignLog>
    implements UsersSignLogService{

    @Override
    public UsersSignLog getBySign() {
        LoginLog loginLog = AuthConstant.getLoginLog();
        String format = DateUtil.format(new Date(), "yyyy-MM-dd");
        QueryWrapper<UsersSignLog> queryWrapper = new QueryWrapper<UsersSignLog>();
        queryWrapper.lambda().eq(UsersSignLog::getUserId,loginLog.getUserId());
        queryWrapper.apply("DATE_FORMAT(CREATE_DATE, '%Y-%m-%d')='"+format+"'");
        UsersSignLog one = this.getOne(queryWrapper);
        return one;
    }
}




